/**
 * 给定二维数组，有空地有障碍有房子
 * 给定操作序列与起点。问从起点开始移动结束后经过多少个房子（不能重复计数）
 * 暴力走一遍打标记即可。
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using Real = long double;
using llt = long long;
using vi = vector<int>;
using vll = vector<llt>;
using pii = pair<int, int>;
using pll = pair<llt, llt>;
using i128 = __int128_t;

pii P[256];

int H, W, X, Y;
vector<string> Board;
string T;

void work(){
    P['U'] = {-1, 0};
    P['D'] = {1, 0};
    P['L'] = {0, -1};
    P['R'] = {0, 1};

    cin >> H >> W >> X >> Y;
    Board.assign(H, {});
    for(auto & s : Board) cin >> s;
    cin >> T;

    vector<vi> Flag(H, vi(W, 0));

    X -= 1, Y -= 1;
    int cnt = 0;

    if(Board[X][Y] == '@'){
        cnt += 1;
        Flag[X][Y] = 1;
    }


    for(auto c : T){
        int nr = X + P[c].first;
        int nc = Y + P[c].second;
        if(0 <= nr and nr < H and 0 <= nc and nc < W and '#' != Board[nr][nc]){
            if('@' == Board[nr][nc]){
                if(Flag[nr][nc] == 0){
                    Flag[nr][nc] = 1;
                    cnt += 1;
                }
            }
            X = nr, Y = nc;
        }
    }

    cout << X + 1 << " " << Y + 1 << " " << cnt << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
    int nofkase = 1;
	// cin >> nofkase;
	while(nofkase--) work();
	return 0;
}